<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : global_menu04_01.jsp
    Description : 설명을 기술합니다.
    author smJeon
    since 2012. 5. 10.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 5. 10.     smJeon     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/com/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/com/include/doctype.jspf" %>
<script>


function fnSerchForm() {
    
    //선택 값을 가져온다        
    var lgrpCdValue = $('#lgrpCdTemp option:selected').val();
    var searchKeywordValue = $('#searchKeywordTemp').val();
    
    //서치폼에 값을 설정한다
    var form = document.serchForm;
    $('#lgrpCd').val(lgrpCdValue);
    $('#searchKeyword').val(searchKeywordValue);
    $('#pageIndex').val(1);
    form.faqSn.value= 0;
    form.action = "<c:url value='/qa/qa/selectQaPaging.do'/>";
    form.submit();
    
}
function fnLinkPage(pageIndex) {
    $("#pageIndex").val(pageIndex);
    
    var form = document.serchForm;
    form.action = "<c:url value='/qa/qa/selectQaPaging.do'/>";
    form.submit();
}

function fnBestSerchForm(faqSn){
  
    var form = document.serchForm;
    $('#faqSn').val(faqSn);
    $('#searchKeyword').val(''); //기존 검색 키워드는 초기화 시킴
    $('#lgrpCd').val(''); //기존 검색 코드 초기화 시킴
    $('#pageIndex').val(1);
    form.action = "<c:url value='/qa/qa/selectQaPaging.do'/>";
    form.submit();
}

function goQna(lgrpCd){
    var form = document.serchForm;
    $('#lgrpCd').val(lgrpCd);
    form.action = "<c:url value='/qa/qa/insertQaDetail.do'/>";
    form.submit();
}

function updateCount(faqSn){
    $.post("<c:url value='/qa/qa/updateCount.do'/>",
            {
                'faqSn' : faqSn
               
            },
            function(data){
                var result={};
                var items = $(data).find("item");
                items.each(function(index,element){
                   var name = $(this).find("name").text();
                   var value = $(this).find("value").text();
                   result[name] = value;
                });
                if(result["result"] =="OK"){
                   
                }
            }  
        );
            
}

$(document).ready(
    function() {

        var lgrpCdValue = "<c:out value="${qaSearchVO.lgrpCd}"/>";
        var searchKeywordValue = "<c:out value="${qaSearchVO.searchKeyword}"/>";
        if(lgrpCdValue != ""){
            $('select[id=lgrpCdTemp] option[value=' + lgrpCdValue + ']').attr('selected', true);
        }
        if(searchKeywordValue != ""){
            $('#searchKeywordTemp').val(searchKeywordValue);
        } 
        
    }
);

</script>
</head>
<body>
<%@ include file="/WEB-INF/jsp/com/include/layerpopup.jspf" %>
<div id="wrap">
	<%@ include file="/WEB-INF/jsp/com/include/navi_utill_sub.jspf" %>
	<%@ include file="/WEB-INF/jsp/com/include/navi_header.jspf" %>
	<hr />

	<%@ include file="/WEB-INF/jsp/com/include/sub_header_global04.jspf" %>
	<hr />

	<div id="container">
		<div id="subtitle-area"><div class="subtitle-area-inner">
			<h4><img src="/kr/images/title/h4_global_menu04_01.gif" alt="FAQ" /></h4>
			<%@ include file="/WEB-INF/jsp/com/include/location.jspf" %>
		</div></div>
		<div id="article">
                 <form method="post" action="" name="serchForm" id="serchForm" onsubmit="return false">
                    <input type="hidden" name="lgrpCd" id="lgrpCd" value="${qaSearchVO.lgrpCd}">
                    <input type="hidden" name="searchKeyword" id="searchKeyword" value="${qaSearchVO.searchKeyword}">
                    <input type="hidden" name="titl" id="titl" value="${qaSearchVO.titl }">
                    <input type="hidden" name="faqSn" id="faqSn" value="${qaSearchVO.faqSn }">
                    <input type="hidden" name="pageIndex" id="pageIndex" value="${qaSearchVO.pageIndex}">
                </form>   
			<div class="faq-best-stats">
				<div class="title-area">
					<h5><img src="/kr/images/title/h5_global_menu04_01.gif" alt="자주묻는 질문 BEST" /></h5>
					<p><img src="/kr/images/title/h5_global_menu04_01_desc.gif" alt="자주 문의하시는 질문에 대한 답변을 한 곳에 모았습니다. FAQ 분류를 통해 질문에 대한 답변을 즉시 확인하실 수 있습니다." /></p>
					<a href="<c:url value="/mpg/QAListPaging.do"/>"><img src="/kr/images/common/button/btn_my_qna.gif" alt="내 상담결과 확인하기" /></a>
				</div>
				<div class="best-stats">
					<ol>
                        <c:forEach var="result" items="${resultBestList}" varStatus="status">
                           <li class="num0${status.count}"><a href="javascript:fnBestSerchForm('${result.faqSn }')"><b>[${result.lgrpNm}]</b>${result.titl}</a></li>
                        </c:forEach>
					</ol>
				</div>
			</div>
			<div class="customer_inquiry_information subsection">
				<img src="/kr/images/global_menu/img_global_menu04_01.gif" alt="고객센터 080-600-6000" class="first" />
				<img src="/kr/images/global_menu/img_global_menu04_02.gif" alt="차량부품상담 1588-7278" />
				<img src="/kr/images/global_menu/img_global_menu04_03.gif" alt="차량구입상담 080-600-6000" />
				<img src="/kr/images/global_menu/img_global_menu04_04.gif" alt="카드상담 1577-6000" />
			</div>

			<div class="toggle_list_wrap subsection">
             <c:set var="rowNum" value="${ paginationInfo.totalRecordCount - (paginationInfo.currentPageNo-1)* paginationInfo.pageSize}" />
              <c:forEach var="result" items="${resultList}" varStatus="status">
                            <!-- row -->
                                <div class="row-wrap">
                                    <div class="row">
                                        <div class="num" title="번호">${rowNum - status.index }</div>
                                        <div class="sort" title="구분">${result.lgrpNm}</div>
                                        <div class="subject" title="제목" onclick="updateCount(${result.faqSn});">${result.titl}</div>
                                    </div>
                                    <div class="answer">${result.sbc}</div>
                                </div>
               </c:forEach>
			</div>
			<div class="paging">
				 <!-- paging SS -->
                <c:if test="${paginationInfo.totalRecordCount > 0 }">
                    <div class="pageing">
                        <able:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fnLinkPage" />
                    </div>
                </c:if>
                <div class="buttonset">
                    <a href="javascript:writeForm()"
                        class="button black"><span><spring:message code='button.regist' /></span>
                    </a>
                </div>
			</div>
			<div class="list-search-form">
				<select name="lgrpCdTemp" id="lgrpCdTemp"  >
                    <option value="">전체</option>
                    <c:forEach var="lgrpItemList" items="${lgrpItemList}" varStatus="status">
                                                            
                        <option value="${lgrpItemList.lgrpCd}" <c:if test="${qaSearchVO.searchKeyword == lgrpItemList.lgrpCd}">selected="selected"</c:if>   >${lgrpItemList.lgrpNm}</option>
                    </c:forEach>
                </select>
				<input type="text" class="text" name="searchKeywordTemp" id="searchKeywordTemp" style="width:227px;" />
                <input type="image" src="/kr/images/common/button/btn_search03.gif" alt="search" style="vertical-align:middle;" onclick="fnSerchForm();" />
			</div>
			<div class="category-sort-select-wrap before-qna">
				<p><img src="/kr/images/global_menu/txt_global_menu04_01.gif"  style="vertical-align:middle;" alt="" />&nbsp;(회원가입 및 로그인 후 이용하실 수 있습니다.)</p>
                <ul class="category-sort-select">
					<li><a href="javascript:goQna('CARBUY')"><img src="/kr/images/global_menu/img_global_menu04_05.gif" alt="차량구매" onclick="goQna('CARBUY')" /></a></li>
					<li><a href="javascript:goQna('CARREP')"><img src="/kr/images/global_menu/img_global_menu04_06.gif" alt="차량정비" onclick="goQna('CARREP')" /></a></li>
					<li><a href="javascript:goQna('REPRES')"><img src="/kr/images/global_menu/img_global_menu04_07.gif" alt="정비예약" onclick="goQna('REPRES')" /></a></li>
					<li><a href="javascript:goQna('HOMEP')"><img src="/kr/images/global_menu/img_global_menu04_08.gif" alt="홈페이지" onclick="goQna('HOMEP')" /></a></li>
					<!-- <a href="javascript:goQna('INVINFO')"><img src="/kr/images/global_menu/img_global_menu04_09.gif" alt="투자정보" /></a>
				    <a href="javascript:goQna('PERHIRE')"><img src="/kr/images/global_menu/img_global_menu04_10.gif" alt="인재채용" /></a> -->
                    <li><a href="javascript:goQna('CTLGCL')"><img src="/kr/images/global_menu/img_global_menu04_13.gif" alt="카탈로그초기화" onclick="goQna('CTLGCL')" /></a></li>
					<li><a href="javascript:goQna('COMPLIM')"><img src="/kr/images/global_menu/img_global_menu04_11.gif" alt="칭찬하기" onclick="goQna('COMPLIM')" /></a></li>
                </ul>
			</div>
		</div>
	</div>
	<hr />
	<%@ include file="/WEB-INF/jsp/com/include/footer.jspf" %>